var arguments = process.argv.splice(2);
var param1 = arguments[0];
// console.log('param1:', param1)

//将字符串转化为json
const str2json = function(srcStr) {
	let json = JSON.parse(srcStr); // (new Function("return " + srcStr))(); // eval('(' + srcStr + ')'); // 
	return json;
}

//-----------------------------------------------------------------------------------------------------

// 获取json长度
const getJsonLength = function (jsonData) {
    //return Object.keys(jsonData).length;
    let jsonLength = 0;
    for (let item in jsonData) {
        jsonLength++;
    }
    return jsonLength;
}

// 获取内部平台题目类型
const getSysType = function (srcType, customAttr, optionList) {
    optionLength = getJsonLength(optionList);
    if (2 == srcType) {//单选题
        if("dropdown" == customAttr.disp_type) {
            return "SINGLE_SELECT";
        }
        return "SINGLE";
    } else if (3 == srcType) {//多选题
        return "MULTIPLE";
    } else if (4 == srcType) {// 矩阵选择题
        return "MATRIX";
    } else if (5 == srcType) {// 矩阵多选
        return "MULTIPLE_MATRIX";
    } else if (6 == srcType) {// 填空题
        if (!customAttr.hasOwnProperty("disp_type")) {
            return "TEXT";
        } else if ("name" == customAttr.disp_type) {//姓名
            return "TEXT";
        } else if ("email" == customAttr.disp_type) {//邮箱
            return "TEXT";
        } else if ("mobile" == customAttr.disp_type) {//手机
            return "TEXT";
        } else if ("date" == customAttr.disp_type) {//日期
            return "DATE";
        } else if ("time" == customAttr.disp_type) {//时间
            return "CASCADE_DROPDOWN";
        } else if ("navigation" == customAttr.disp_type) {//地图导航题
            return "地图导航";
        }
    } else if (7 == srcType) {// 矩阵打分题
        return "MATRIX";
    } else if (8 == srcType) {// 级联题
        return "CASCADE_DROPDOWN";
    } else if (9 == srcType) {// 
    } else if (10 == srcType) {// 
    } else if (50 == srcType) {// 量表，默认5级
        if (!customAttr.hasOwnProperty("disp_type")) {//打分题
            if (optionLength > 1) {// 多行
                return "MATRIX";
            }
            return "SCALE";// 单行
        } else if ("evaluation" == customAttr.disp_type) {//评价题，最多5星好评，可以有文本评价
            return "SCALE";
        } else if ("scale" == customAttr.disp_type) {//量表题，编辑时为小圆圈，答题时为长方块
            return "SCALE";
        } else if ("nps_score" == customAttr.disp_type) {//nps题，值域：0~10
            return "SCALE";
        } else if ("proportion" == customAttr.disp_type) {//比重题，值域：0~100
            return "RATE";
        } else if ("matrix_scale" == customAttr.disp_type) {//矩阵量表题or矩阵打分题
            return "MATRIX";
        }
    } else if (60 == srcType) {// 排序题
        return "SORTED";
    } else if (70 == srcType) {// 占位题
        return "DESCRIPTION";
        // if (!customAttr.hasOwnProperty("disp_type")) {//备注说明题
        //     return "备注说明";
        // } else if ("split_line" == customAttr.disp_type) {//分割线
        //     return "DESCRIPTION";
        // }
    } else if (95 == srcType) {// 多项填空
        if (!customAttr.hasOwnProperty("disp_type")) {//多项填空
            return "MULTIPLE_TEXT";
        } else if ("horz_blank" == customAttr.disp_type) {//横向填空
            return "MULTIPLE_TEXT";
        } else if ("signauto_tableature" == customAttr.disp_type) {//自增表格

        } else if ("signature" == customAttr.disp_type) {//电子签名

        } else if ("geographical_multiple_blank" == customAttr.disp_type) {//所在地理位置

        } else if ("upload_file" == customAttr.disp_type) {//上传文件

        } else if ("image_upload" == customAttr.disp_type) {//上传图片

        } else if ("date" == customAttr.disp_type) {//日期
            return "DATE";
        } else if ("time" == customAttr.disp_type) {//时间
            return "CASCADE_DROPDOWN";
        }
    } else if (100 == srcType) {//矩阵填空题
        return "MATRIX_TEXT";
    } else if (105 == srcType) {//商品题
        return "商品题";
    }
    return "未知题型";//不能处理的类型
}

// 设置题目维度跳题，如果存在的话
const setJumpOnQstIfExist = function (curQst, jumpIdList) {
    let lenOfJIL = getJsonLength(jumpIdList);
    if (lenOfJIL > 0) {
        curQst.is_jump = true; // 是否是跳题 "1" || True | ""
        curQst.jump_to = jumpIdList; // 跳到哪个题目 "" / title_id
    }
}

// 设置选项维度跳题，如果存在的话
const setJumpOnOptIfExist = function (curQst, option, jumpSrcDict) {
    if (undefined == jumpSrcDict) {
        return;
    }
    if (curQst.is_jump) {
        let jumpArr = jumpSrcDict[curQst.title_id];
        let lenOfJA = getJsonLength(jumpArr);
        for (let j = 0; j < lenOfJA; j++) {
            let condArr = jumpArr[j].condition.condition_item_list;
            let lenOfCA = getJsonLength(condArr);
            for (let k = 0; k < lenOfCA; k++) {
                if (option.real_value == condArr[k].option_id) {//当前选项存在跳题逻辑
                    option.is_jump = true; // 是否跳题
                    option.jump_to = jumpArr[j].next_qid; // 跳到第几题
                }
            }
        }
    }
}

// 获取选项
const getOptions = function (srcQstData, curQst, jumpSrcDict, dataIndexDict) {
    let optArr = new Array();
    let optionList = srcQstData.option_list;
    let customAttr = srcQstData.custom_attr;
    let len = getJsonLength(optionList);
    if("SCALE" == curQst.sys_type) { // 量表
        len = customAttr.max_answer_num;
    }
    //{"lastDataIndex" : 0, "curQstDataIndex":[]};
    let lastDataIndex = dataIndexDict["lastDataIndex"];
    for (let i = 0; i < len; i++) {
        let option = new Object();
        option.tid = curQst.tid; //题目计数序号-和题目外部一样
        option.title_id = curQst.title_id; // 题目标题id-和题目外部一样
        option.title_type = curQst.title_type; // 和题目外部一样
        option.sys_type = curQst.sys_type; // 和题目外部一样
        if ("SCALE" == curQst.sys_type) {// 量表
            if(1 == i+1) {
                option.name = undefined == customAttr.desc_left? "":customAttr.desc_left; // 题目的选项名称
            } else if(len == i+1) {
                option.name = undefined == customAttr.desc_right? "":customAttr.desc_right; // 题目的选项名称
            } else {
                option.name = "";
            }
            option.value = (i+1).toString(); // 题目的选项值
            option.real_value = optionList[0]._id.$oid; // 问卷提交对应的值
            if("evaluation" == customAttr.disp_type) {//评价题
                let labelList = optionList[1].custom_attr.label_data[(i+1).toString()].label_list.join("|");
                let scoreDesc = optionList[1].custom_attr.label_data[(i+1).toString()].score_desc;
                option.name = scoreDesc;
                option.text = optionList[1]._id.$oid +"_"+ labelList;
            }
        } else {
            option.name = optionList[i].title; // 题目的选项名称
            option.value = (i+1).toString();
            option.real_value = optionList[i]._id.$oid; // 问卷提交对应的值
            option.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
        }
        option.title = curQst.title + option.name; // 改成和问卷星解析一样：题目标题+选项名称
        option.is_jump = false; // 是否跳题
        option.jump_to = ""; // 跳到第几题
        setJumpOnOptIfExist(curQst, option, jumpSrcDict); //设置选项维度跳题逻辑，如果存在的话

        option.req = curQst.req; // 是否必须 - 和题目外部一样
        option.is_text = curQst.is_text; // 是否需要填空 - 默认false
        option.relation = ""; // 关联 - 内部不需要这个字段
        option.min_oper_num = curQst.min_oper_num; // 最小值
        option.max_oper_num = curQst.max_oper_num; // 最大值
        option.rate = 0; // 权重 - 默认0 - 非问卷解析字段
        // option.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
        option.is_reverse = false; // 是否反向 - 默认false
        option.options = []; // 选项
        option.children = []; // 针对矩阵题
        if("MULTIPLE" == curQst.sys_type || "SORTED" == curQst.sys_type || "RATE" == curQst.sys_type 
            || "CASCADE_DROPDOWN" == curQst.sys_type) {//多选和排序每个选项都要有索引，级联和时间也需要，比重题每一行要有一个
            option.data_index = lastDataIndex + i; // 数据库索引
            dataIndexDict["curQstDataIndex"].push(lastDataIndex + i);
        } else {
            option.data_index = lastDataIndex; // 数据库索引
        }
        option.is_repeat = false; // 是否去重 - 解析默认false
        optArr.push(option);
    }
    if("MULTIPLE" == curQst.sys_type || "SORTED" == curQst.sys_type || "RATE" == curQst.sys_type || "CASCADE_DROPDOWN" == curQst.sys_type) {
        dataIndexDict["lastDataIndex"] = lastDataIndex + len;
    } else if("DESCRIPTION" == curQst.sys_type) {
        //描述类占位题不生成dataIndexDict值
    } else {
        dataIndexDict["curQstDataIndex"].push(lastDataIndex);
        dataIndexDict["lastDataIndex"] = lastDataIndex + 1;
    }
    return optArr;
}

// 获取data_index的多选选项
const getDataIdxMultiOption = function (optionList, curQst, jumpSrcDict, dataIndexDict) {
    let optArr = new Array();
    //{"lastDataIndex" : 0, "curQstDataIndex":[]};
    let lastDataIndex = dataIndexDict["lastDataIndex"];
    for (let i = 0; i < 1; i++) {
        let option = new Object();
        option.tid = curQst.tid; //题目计数序号-和题目外部一样
        option.title_id = curQst.title_id; // 题目标题id-和题目外部一样
        option.title_type = curQst.title_type; // 和题目外部一样
        option.sys_type = curQst.sys_type; // 和题目外部一样
        option.name = optionList[i].title; // 题目的选项名称
        option.title = curQst.title + option.name; // 改成和问卷星解析一样：题目标题+选项名称
        option.value = i+1;
        option.real_value = optionList[i]._id.$oid; // 问卷提交对应的值

        option.is_jump = false; // 是否跳题
        option.jump_to = ""; // 跳到第几题
        setJumpOnOptIfExist(curQst, option, jumpSrcDict); //设置选项维度跳题逻辑，如果存在的话

        option.req = curQst.req; // 是否必须 - 和题目外部一样
        option.is_text = false; // 是否需要填空 - 默认false
        option.relation = ""; // 关联 - 内部不需要这个字段
        option.min_oper_num = curQst.min_oper_num; // 最小值
        option.max_oper_num = curQst.max_oper_num; // 最大值
        option.rate = 0; // 权重 - 默认0 - 非问卷解析字段
        option.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
        option.is_reverse = false; // 是否反向 - 默认false
        option.options = []; // 选项
        option.children = []; // 针对矩阵题
        option.data_index = lastDataIndex; // 数据库索引
        option.is_repeat = false; // 是否去重 - 解析默认false
        optArr.push(option);
    }
    return optArr;
}

// 获取子节点选项（只针对矩阵or多填）
const getChildOption = function (optionList, curQst, srcQstData) {
    let optArr = new Array();
    let len = getJsonLength(optionList);
    for (let i = 0; i < len; i++) {
        let option = new Object();
        option.tid = curQst.tid; //题目计数序号-和题目外部一样
        option.title_id = curQst.title_id; // 题目标题id-和题目外部一样
        option.title = curQst.title + optionList[i].title; // 父题目+本title
        option.title_type = curQst.title_type; // 和题目外部一样
        option.sys_type = curQst.sys_type; // 和题目外部一样
        option.name = optionList[i].title; // 题目的选项名称
        option.value = i+1;
        if(7 == srcQstData.question_type) {//矩阵打分题
            option.value = option.name
        }
        option.real_value = (optionList[i]._id.$oid).toString(); // 问卷提交对应的值
        option.is_jump = false; // 是否跳题
        option.jump_to = ""; // 跳到第几题
        option.req = curQst.req; // 是否必须 - 和题目外部一样
        option.is_text = curQst.is_text; // 是否需要填空 - 默认false
        option.relation = ""; // 关联 - 内部不需要这个字段
        option.min_oper_num = curQst.min_oper_num; // 最小值
        option.max_oper_num = curQst.max_oper_num; // 最大值
        option.rate = 0; // 权重 - 默认0 - 非问卷解析字段
        option.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
        option.is_reverse = false; // 是否反向 - 默认false
        option.options = []; // 选项
        option.children = []; // 针对矩阵题
        option.data_index = curQst.data_index; // 数据库索引
        option.is_repeat = false; // 是否去重 - 解析默认false
        optArr.push(option);
    }
    return optArr;
}

// 获取矩阵多选的子节点选项
const getChildOptionOnly4MultiMatrix = function(optionList, curQst, dataIndexDict) {
    let lastDataIndex = dataIndexDict["lastDataIndex"];
    let optArr = new Array();
    let len = getJsonLength(optionList);
    for (let i = 0; i < len; i++) {
        let option = new Object();
        option.tid = curQst.tid; //题目计数序号-和题目外部一样
        option.title_id = curQst.title_id; // 题目标题id-和题目外部一样
        option.title = curQst.title + optionList[i].title; // 父题目+本title
        option.title_type = curQst.title_type; // 和题目外部一样
        option.sys_type = curQst.sys_type; // 和题目外部一样
        option.name = optionList[i].title; // 题目的选项名称
        option.value = i+1;
        option.real_value = (optionList[i]._id.$oid).toString(); // 问卷提交对应的值
        option.is_jump = false; // 是否跳题
        option.jump_to = ""; // 跳到第几题
        option.req = curQst.req; // 是否必须 - 和题目外部一样
        option.is_text = curQst.is_text; // 是否需要填空 - 默认false
        option.relation = ""; // 关联 - 内部不需要这个字段
        option.min_oper_num = curQst.min_oper_num; // 最小值
        option.max_oper_num = curQst.max_oper_num; // 最大值
        option.rate = 0; // 权重 - 默认0 - 非问卷解析字段
        option.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
        option.is_reverse = false; // 是否反向 - 默认false
        option.options = []; // 选项
        option.children = []; // 针对矩阵题
        option.data_index = lastDataIndex + i; // 数据库索引
        option.is_repeat = false; // 是否去重 - 解析默认false
        optArr.push(option);
        dataIndexDict["curQstDataIndex"].push(lastDataIndex + i);
    }
    dataIndexDict["lastDataIndex"] = lastDataIndex + len;
    return optArr;
}

//获取矩阵量表的子节点选项
const  getChildOption4MatrixScale = function(curQst, srcQstData, curChild) {
    let optArr = new Array();
    let ca = srcQstData.custom_attr;
    let counter = 1;
    for (let i = ca.min_answer_num; i <= ca.max_answer_num; i = i+ca.magnitude_scale) {
        let option = new Object();
        option.tid = curQst.tid; //题目计数序号-和题目外部一样
        option.title_id = curQst.title_id; // 题目标题id-和题目外部一样
        option.title_type = curQst.title_type; // 和题目外部一样
        option.sys_type = curQst.sys_type; // 和题目外部一样
        option.name = ""; // 题目的选项名称
        if (!ca.hasOwnProperty("desc_left")) {
            ca["desc_left"] = "";
        }
        if (!ca.hasOwnProperty("desc_right")) {
            ca["desc_right"] = "";
        }
        if(i == ca.min_answer_num) {
            option.title += ca.desc_left;
            option.name = ca.desc_left;
        } else if (i == ca.max_answer_num) {
            option.title += ca.desc_right;
            option.name = ca.desc_right;
        }
        option.title = curQst.title + option.name; // 父题目+本title
        option.value = counter;
        option.real_value = (i).toString(); // 问卷提交对应的值
        option.is_jump = false; // 是否跳题
        option.jump_to = ""; // 跳到第几题
        option.req = curQst.req; // 是否必须 - 和题目外部一样
        option.is_text = curQst.is_text; // 是否需要填空 - 默认false
        option.relation = ""; // 关联 - 内部不需要这个字段
        option.min_oper_num = curQst.min_oper_num; // 最小值
        option.max_oper_num = curQst.max_oper_num; // 最大值
        option.rate = 0; // 权重 - 默认0 - 非问卷解析字段
        option.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
        option.is_reverse = false; // 是否反向 - 默认false
        option.options = []; // 选项
        option.children = []; // 针对矩阵题
        option.data_index = curQst.data_index; // 数据库索引
        option.is_repeat = false; // 是否去重 - 解析默认false
        optArr.push(option);
        counter++;
    }
    return optArr;
}

//构建矩阵量表(or打分题多行场景)子项
const buildMatrixScaleChildren = function(srcQstData, curQst, dataIndexDict, childArr) {
    let matrixRows = srcQstData.option_list;
    let len = getJsonLength(matrixRows);
    for (let i = 0; i < len; i++) {
        let curChild = new Object();
        curChild.tid = curQst.tid; //题目计数序号-和题目外部一样
        curChild.title_id = curQst.title_id; // 题目标题id-和题目外部一样
        curChild.title = curQst.title + matrixRows[i].title; //  parent的title + child的name组成一个title
        curChild.title_type = curQst.title_type; // 和题目外部一样
        curChild.sys_type = curQst.sys_type; // 和题目外部一样
        curChild.name = matrixRows[i].title; // 题目的选项名称
        curChild.value = i+1;
        curChild.real_value = matrixRows[i]._id.$oid; // 问卷提交对应的值
        curChild.is_jump = false; // 是否跳题
        curChild.jump_to = ""; // 跳到第几题
        curChild.req = curQst.req; // 是否必须 - 和题目外部一样
        curChild.is_text = false; // 是否需要填空 - 默认false
        curChild.relation = ""; // 关联 - 内部不需要这个字段
        curChild.min_oper_num = 0; // 最小值
        curChild.max_oper_num = 0; // 最大值
        setMaxAndMinIfExist(curChild, srcQstData);
        curChild.rate = 0; // 权重 - 默认0 - 非问卷解析字段
        curChild.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
        curChild.is_reverse = false; // 是否反向 - 默认false            
        curChild.data_index = dataIndexDict["lastDataIndex"] + i; // 数据库索引
        dataIndexDict["curQstDataIndex"].push(dataIndexDict["lastDataIndex"] + i);
        curChild.options = getChildOption4MatrixScale(curQst, srcQstData, curChild); // 选项
        curChild.children = []; // 针对矩阵题
        curChild.is_repeat = false; // 是否去重 - 解析默认false
        childArr.push(curChild);
    }
    dataIndexDict["lastDataIndex"] = dataIndexDict["lastDataIndex"] + len;
}

// 获取矩阵打分题的选项列表
const getOptionListOfMatrixScale = function(srcQstData, curQst) {
    let optionList = new Array();
    let ca = srcQstData.custom_attr;
    let min_answer = ca.min_answer_num;
    let max_answer = ca.max_answer_num;
    let step = ca.magnitude_scale;
    let titleArr = curQst.title.split('_');
    let oid = '';
    if(titleArr.length > 1) {
        oid = titleArr[titleArr.length - 1];
    }
    for (let i = min_answer; i <= max_answer; i = i+step) { // 获取从最小值到最大值，步长为step
        let option = new Object();
        option.title = i.toString();
        id = {"_id": {
                    "$oid": oid
                }
            }
        option._id = id._id;
        optionList.push(option);
    }
    return optionList;
}

// 获取子选项（只针对矩阵or多填）
const getChildren = function (srcQstData, curQst, dataIndexDict) {
    let childArr = new Array();
    let len = 0;
    let matrixRowList = srcQstData.matrixrow_list;
    let optionList = srcQstData.option_list;
    let customAttr = srcQstData.custom_attr;
    //{"lastDataIndex" : 0, "curQstDataIndex":[]};
    let lastDataIndex = dataIndexDict["lastDataIndex"];
    if ("MATRIX" == curQst.sys_type || "MULTIPLE_MATRIX" == curQst.sys_type || "MATRIX_TEXT" == curQst.sys_type) {//矩阵单选，矩阵量表，矩阵多选，矩阵填空
        len = getJsonLength(matrixRowList);
        if(0 == len && 50 == srcQstData.question_type) {//矩阵量表题or打分题(多行)
            buildMatrixScaleChildren(srcQstData, curQst, dataIndexDict, childArr);
        } else if(7 == srcQstData.question_type) {//矩阵打分题
            optionList = getOptionListOfMatrixScale(srcQstData, curQst);
            let titleArr = curQst.title.split('_');
            let oid = '';
            if (titleArr.length > 1) {
                oid = titleArr[titleArr.length - 1];
            }
            curQst.title = curQst.title.substring(0, curQst.title.length - oid.length);
        }
        for (let i = 0; i < len; i++) {
            let curChild = new Object();
            curChild.tid = curQst.tid; //题目计数序号-和题目外部一样
            curChild.title_id = curQst.title_id; // 题目标题id-和题目外部一样
            curChild.title = curQst.title + matrixRowList[i].title; //  parent的title + child的name组成一个title
            curChild.title_type = curQst.title_type; // 和题目外部一样
            curChild.sys_type = curQst.sys_type; // 和题目外部一样
            curChild.name = matrixRowList[i].title; // 题目的选项名称
            curChild.value = i+1;
            curChild.real_value = matrixRowList[i]._id.$oid; // 问卷提交对应的值
            curChild.is_jump = false; // 是否跳题
            curChild.jump_to = ""; // 跳到第几题
            curChild.req = curQst.req; // 是否必须 - 和题目外部一样
            curChild.is_text = false; // 是否需要填空 - 默认false
            curChild.relation = ""; // 关联 - 内部不需要这个字段
            curChild.min_oper_num = 0; // 最小值
            curChild.max_oper_num = 0; // 最大值
            setMaxAndMinIfExist(curChild, srcQstData);
            curChild.rate = 0; // 权重 - 默认0 - 非问卷解析字段
            curChild.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
            curChild.is_reverse = false; // 是否反向 - 默认false
            curChild.data_index = lastDataIndex + i; // 数据库索引
            if("MULTIPLE_MATRIX" == curQst.sys_type || "MATRIX_TEXT" == curQst.sys_type) {//矩阵多选or矩阵填空
                curChild.options = getChildOptionOnly4MultiMatrix(optionList, curChild, dataIndexDict); // 选项
                curChild.data_index = dataIndexDict["lastDataIndex"]; // 数据库索引
                // dataIndexDict["curQstDataIndex"].push(dataIndexDict["lastDataIndex"]);
                // dataIndexDict["lastDataIndex"] = dataIndexDict["lastDataIndex"] + 1;
            } else {
                curChild.data_index = dataIndexDict["lastDataIndex"] + i; // 数据库索引
                dataIndexDict["curQstDataIndex"].push(dataIndexDict["lastDataIndex"] + i);
                curChild.options = getChildOption(optionList, curChild, srcQstData); // 选项
            }
            curChild.children = []; // 针对矩阵题
            curChild.is_repeat = false; // 是否去重 - 解析默认false
            childArr.push(curChild);
        }
        if("MULTIPLE_MATRIX" != curQst.sys_type && "MATRIX_TEXT" != curQst.sys_type) {//不是矩阵多选和矩阵填空
            dataIndexDict["lastDataIndex"] = dataIndexDict["lastDataIndex"] + len;
        }
    } else if("MULTIPLE_TEXT" == curQst.sys_type) { //多项填空 
        len = getJsonLength(optionList);
        for (let i = 0; i < len; i++) {
            let curChild = new Object();
            curChild.tid = curQst.tid; //题目计数序号-和题目外部一样
            curChild.title_id = curQst.title_id; // 题目标题id-和题目外部一样
            curChild.title = curQst.title + optionList[i].title; //  parent的title + child的name组成一个title
            curChild.title_type = curQst.title_type; // 和题目外部一样
            curChild.sys_type = curQst.sys_type; // 和题目外部一样
            curChild.name = optionList[i].title; // 题目的选项名称
            curChild.value = i+1;
            curChild.real_value = optionList[i]._id.$oid; // 问卷提交对应的值
            curChild.is_jump = false; // 是否跳题
            curChild.jump_to = ""; // 跳到第几题
            curChild.req = curQst.req; // 是否必须 - 和题目外部一样
            curChild.is_text = true; // 是否需要填空 - 默认false
            curChild.relation = ""; // 关联 - 内部不需要这个字段
            curChild.min_oper_num = 0; // 最小值
            curChild.max_oper_num = 0; // 最大值
            curChild.rate = 0; // 权重 - 默认0 - 非问卷解析字段
            curChild.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
            curChild.is_reverse = false; // 是否反向 - 默认false
            curChild.data_index = lastDataIndex + i; // 数据库索引
            curChild.options = getChildOption([optionList[i]], curChild, srcQstData); // 选项
            curChild.children = []; // 针对矩阵or多填题
            curChild.is_repeat = false; // 是否去重 - 解析默认false
            childArr.push(curChild);
            dataIndexDict["curQstDataIndex"].push(lastDataIndex + i);
        }
        dataIndexDict["lastDataIndex"] = dataIndexDict["lastDataIndex"] + len;
    } else {//...  

    }
    return childArr;
}

// 获取是否必填：0代表非必填；1代表必填
const getRequired = function (customAttr) {
    if (customAttr.hasOwnProperty("allow_null") && "on" == customAttr.allow_null) {
        return '0';
    }
    return '1';
}

// 处理关联的字符串逻辑。
const genRelateStr = function (itemOptionId, relObj, optSymbal, optionIndex) {
    var retString = '';
    if (itemOptionId === 'any') { // 所有。
        for (var k = 0; k < relObj.options.length; k++) {
            //var tempOpt = relObj.options[k];
            retString += optSymbal;
            retString += (k + 1) + (optSymbal === '-' ? "." : ";"); //
        }
        if (retString.endsWith(';') || retString.endsWith('.')) {
            retString = retString.substr(0, retString.length - 1);
        }
    } else {
        retString += optSymbal;
        retString += (optionIndex + 1); // 获取到的Index与ID有且不。
    }
    return retString;
};

// 逻辑连接符号。
const logicalConnect = function (relate, oldId, newId, conditionType) {
    const isNew = oldId !== newId;
    var result = '';
    if (relate !== '') {
        if (conditionType === 2) {// 或逻辑。&;
            result = isNew ? (`$${newId},`) : ";";
        } else {
            result = isNew ? (`|${newId},`) : ".";  // 与逻辑。|+.
        }
        return result;
    }
    return newId + ",";
};

// 获取显示逻辑（关联关系）
const getDisplay = function (ret, srcData, qstId) {
    let isDisplay = true;
    let displayConstraint = srcData.DISPLAYCONSTRAINT_SOURCE_Q_DICT === undefined ? undefined : srcData.DISPLAYCONSTRAINT_SOURCE_Q_DICT[qstId];
    if (displayConstraint == undefined) {
        displayConstraint = srcData.HIDDENCONSTRAINT_SOURCE_Q_DICT === undefined ? undefined : srcData.HIDDENCONSTRAINT_SOURCE_Q_DICT[qstId];
        isDisplay = false;
    }

    let relation = '';
    if (displayConstraint !== undefined) {
        let lastTid = '';
        // 显示逻辑处理有问题。
        Object.keys(displayConstraint).forEach(key => { // for (let key in displaySrcDict) {//
            let dispDictArr = displayConstraint[key];
            let lenOfDA = getJsonLength(dispDictArr);
            for (let i = 0; i < lenOfDA; i++) {
                var logicBlock = dispDictArr[i];
                var item = logicBlock.condition.condition_item_list[0];
                var logicRelation = logicBlock.condition.logic_relation;
                var operationType = item.operation_type; // 1 表示选中； 2 表示不选中。3：表示显示（一般是any）；  4：不显示（一般是any） ？，其它不管。
                var itemQid = item.question_id;
                var itemOptionId = item.option_id;
                var relObj = ret.find(u => u.title_id === itemQid);
                //console.log("显示逻辑:" + itemQid + ";" + itemOptionId + ";" + operationType + ";" + logicRelation);
                if (operationType !== 1 && operationType !== 2 && itemOptionId !== 'any') {
                    relation = "【不支持的关联方式】" + operationType;
                    break;
                }
                if (relObj === undefined) {
                    continue;
                }
                if (operationType == 5) {//补充HIDDENCONSTRAINT_SOURCE_Q_DIC场景处理
                    continue;
                }
                var optSymbal = (operationType === 2 || operationType === 4) ? '-' : ''; //  选项符号。
                if (!isDisplay) {//补充HIDDENCONSTRAINT_SOURCE_Q_DIC场景处理
                    optSymbal = optSymbal == '-' ? '' : '-';
                }
                var optionIndex = relObj.options.findIndex(u => u.real_value === itemOptionId);

                relation += logicalConnect(relation, lastTid, relObj.tid, logicRelation);
                relation += genRelateStr(itemOptionId, relObj, optSymbal, optionIndex);
                lastTid = relObj.tid;
            }
        });
    }
    return relation;
}

// 获取显示逻辑-new（关联关系）
const getDisplayNew = function (displaySrcDict, displayIdList, qstId) {
    let lenOfDIL = getJsonLength(displayIdList);
    if (lenOfDIL == 0) {
        return "";
    }

    let result = "";
    let tmpDict = {};
    Object.keys(displaySrcDict).forEach(key => { // for (let key in displaySrcDict) {//
        if (key == qstId) {
            let innerDict = displaySrcDict[key];
            Object.keys(innerDict).forEach(ikey => {// for (let ikey in innerDict) {//
                let dispArr = innerDict[ikey];
                let lenOfDA = getJsonLength(dispArr);
                for (let i = 0; i < lenOfDA; i++) {
                    let condArr = dispArr[i].condition.condition_item_list;
                    let lenOfCA = getJsonLength(condArr);
                    for (let j = 0; j < lenOfCA; j++) {
                        let srcOptId = condArr[j].option_id;
                        let srcQstId = condArr[j].question_id;
                        result = srcQstId + "," + srcOptId;
                        // if(undefined == tmpDict[srcQstId]) {
                        //     tmpDict[srcQstId] = srcOptId;
                        // } else {
                        //     let tmpOptId = tmpDict[srcQstId];
                        //     tmpDict[srcQstId] = tmpOptId + ";" + srcOptId;
                        // }
                    }
                }
            });
        }
    });
    return result;
}

// 设置最大最小值，如果存在的话
const setMaxAndMinIfExist = function (curQst, srcQstData) {
    let customAttr = srcQstData.custom_attr
    if("SCALE" == curQst.sys_type) { //量表不设置max和min
        return;
    }
    let minVal = customAttr.min_answer_num;
    let maxVal = customAttr.max_answer_num;
    if(undefined != minVal && "" != minVal) {
        curQst.min_oper_num = minVal;
    }
    if(undefined != maxVal && "" != maxVal) {
        curQst.max_oper_num = maxVal;
    }
    if("MULTIPLE" == curQst.sys_type && 0 == curQst.max_oper_num) {//多选要设置最大值，如果没有预设max则取选项数量
        curQst.max_oper_num = getJsonLength(srcQstData.option_list);
    }
}

// 判断是否为填空类题型
const isText = function (curQst, customAttr) {
    if("TEXT" == curQst.sys_type || "DATE" == curQst.sys_type || "MULTIPLE_TEXT" == curQst.sys_type || "MATRIX_TEXT" == curQst.sys_type) {
        return true;
    }
    return false;
}

// 获取data_index数据中的多选选项
const getDataIdxCheckboxOption = function (curQst, dataIndexDict, idx) {
    let lastDataIndex = dataIndexDict["lastDataIndex"];
    let option = new Object();
    option.tid = curQst.tid; //题目计数序号-和题目外部一样
    option.title_id = curQst.title_id; // 题目标题id-和题目外部一样
    option.title_type = curQst.title_type; // 和题目外部一样
    option.sys_type = curQst.sys_type; // 和题目外部一样
    option.name = curQst.name; // 题目的选项名称
    option.title = curQst.title + option.name; //  parent的title + option的name组成一个title
    option.value = idx + 1;
    option.real_value = curQst.value; // 问卷提交对应的值
    option.is_jump = false; // 是否跳题
    option.jump_to = ""; // 跳到第几题
    option.req = curQst.req; // 是否必须 - 和题目外部一样
    option.is_text = curQst.is_text; // 是否需要填空 - 默认false
    option.relation = ""; // 关联 - 内部不需要这个字段
    option.min_oper_num = curQst.min_oper_num; // 最小值
    option.max_oper_num = curQst.max_oper_num; // 最大值
    option.rate = 0; // 权重 - 默认0 - 非问卷解析字段
    option.text = ""; // 填空内容 - 默认空字符串 - 非问卷解析字段
    option.is_reverse = false; // 是否反向 - 默认false
    option.options = []; // 选项
    option.children = []; // 针对矩阵or多填
    option.data_index = lastDataIndex; // 数据库索引
    option.is_repeat = false; // 是否去重 - 解析默认false
    dataIndexDict["curQstDataIndex"].push(lastDataIndex);
    dataIndexDict["lastDataIndex"] = lastDataIndex + 1;
    return option;
}

// 深度拷贝对象
function deepClone(source) {
    if (typeof source !== 'object' || source == null) {
        return source;
    }
    const target = Array.isArray(source) ? [] : {};
    for (const key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
            if (typeof source[key] === 'object' && source[key] !== null) {
                target[key] = deepClone(source[key]);
            } else {
                target[key] = source[key];
            }
        }
    }
    return target;
}

// 获取data_index数据
const getDataIndexArr = function(srcData) {
    let dataIndexArr = new Array(); // 数据库对应的数据

    let counter = 0;
    let questions = srcData.QUESTION_DICT;
    let dataIndexDict = {"lastDataIndex" : 0, "curQstDataIndex":[]};//用于记录上一个索引，和当前题目data_index集合
    Object.keys(questions).forEach(key => { // for (let key in questions) {//
        //console.log(key);
        // if ("MULTIPLE" == getSysType(questions[key].question_type, questions[key].custom_attr)) {
        //     let optionList = questions[key].option_list;
        //     let len = getJsonLength(optionList);
        //     for (let i = 0; i < len; i++) {
        //         let tmp = new Object();
        // 		tmp.index = counter++; // 数据索引
        // 		tmp.title_id = key; // 题目id_每个问卷每个题目唯一标识，提交用
        // 		tmp.title = key + questions[key].title + optionList[i].title; // 题目的标题，title_id + 标题字符串
        // 		tmp.title_type = questions[key].question_type; // 题目类型_每个平台自己的题目类型_1_23
        // 		tmp.sys_type = getSysType(tmp.title_type, questions[key].custom_attr); // 内部平台题目类型
        // 		tmp.name = tmp.title; // 题目名称，同title
        // 		tmp.value = ""; // 值 - 题目维度下不需要填
        // 		tmp.is_jump = false; // 是否是跳题 "1" || True | ""
        // 		tmp.jump_to = ""; // 跳到哪个题目 "" / title_id
        // 		setJumpOnQstIfExist(tmp, questions[key].jumpconstraint_id_list2);
        // 		tmp.req = getRequired(questions[key].custom_attr); // 是否必须题 "1" / "0" || ""
        // 		tmp.is_text = "TEXT" == tmp.sys_type ? true : false;// 是否填空题 bool
        // 		tmp.is_repeat = false; // 是否去重 - 题目维度下不需要填 - 对于解析来说，默认false
        // 		tmp.text = ""; // 填空内容 - 题目维度下不需要填
        // 		tmp.relation = getDisplay(dataIndexArr, srcData, key);
        // 		// tmp.relation = getDisplayNew(srcData.DISPLAYCONSTRAINT_SOURCE_Q_DICT, questions[key].displayconstraint_id_list2, key); // 关联哪个题目(显示逻辑) 7,1;2;3|8,2;3
        // 		tmp.min_oper_num = 0; // 最小值
        // 		tmp.max_oper_num = 0; // 最大值
        // 		setMaxAndMinIfExist(tmp, questions[key]);
        // 		tmp.rate = ""; // 权重 - 题目维度下不需要填
        // 		tmp.is_reverse = ""; //是否反转 - 题目维度下不需要填
        // 		tmp.options = [getDataIdxCheckboxOption(tmp, dataIndexDict, i)];
        // 		tmp.children = [];
        //         tmp.data_index = dataIndexDict["curQstDataIndex"]; // 数据库索引
        //         dataIndexDict["curQstDataIndex"] = [];

        //         dataIndexArr.push(tmp);
        //     }
        // } else {
        let tmp = new Object();
        tmp.index = counter++; // 数据索引
        tmp.tid = counter; // 题目的计数序号，唯一但不用于提交，可在relation中使用
        tmp.title_id = key; // 题目id_每个问卷每个题目唯一标识，提交用
        tmp.title = key + questions[key].title; // 题目的标题，title_id + 标题字符串
        tmp.title_type = questions[key].question_type; // 题目类型_每个平台自己的题目类型_1_23
        tmp.sys_type = getSysType(tmp.title_type, questions[key].custom_attr, questions[key].option_list); // 内部平台题目类型
        tmp.name = questions[key].title; // 题目名称，给制单人看的
        tmp.value = ""; // 值 - 题目维度下不需要填
        tmp.is_jump = false; // 是否是跳题 "1" || True | ""
        tmp.jump_to = ""; // 跳到哪个题目 "" / title_id
        setJumpOnQstIfExist(tmp, questions[key].jumpconstraint_id_list2);
        tmp.req = getRequired(questions[key].custom_attr); // 是否必须题 "1" / "0" || ""
        tmp.is_text = "TEXT" == tmp.sys_type ? true : false;// 是否填空题 bool
        tmp.is_repeat = false; // 是否去重 - 题目维度下不需要填 - 对于解析来说，默认false
        tmp.text = ""; // 填空内容 - 题目维度下不需要填
        tmp.relation = getDisplay(dataIndexArr, srcData, key);
        // tmp.relation = getDisplayNew(srcData.DISPLAYCONSTRAINT_SOURCE_Q_DICT, questions[key].displayconstraint_id_list2, key); // 关联哪个题目(显示逻辑) 7,1;2;3|8,2;3
        tmp.min_oper_num = 0; // 最小值
        tmp.max_oper_num = 0; // 最大值
        setMaxAndMinIfExist(tmp, questions[key]);
        tmp.rate = ""; // 权重 - 题目维度下不需要填
        tmp.is_reverse = ""; //是否反转 - 题目维度下不需要填
        tmp.options = [];
        tmp.children = [];
        if("MATRIX" == tmp.sys_type || "MULTIPLE_MATRIX" == tmp.sys_type || "MATRIX_TEXT" == tmp.sys_type
            || "MULTIPLE_TEXT" == tmp.sys_type) { // 矩阵or多填题
            if (7 == questions[key].question_type) {//矩阵打分题
                questions[key].option_list.forEach(option => { 
                    let newTmp = deepClone(tmp);
                    newTmp.title = tmp.title + "_" + option.title + "_" + option._id.$oid;
                    newTmp.children = getChildren(questions[key], newTmp, dataIndexDict);
                    newTmp.data_index = dataIndexDict["curQstDataIndex"]; // 数据库索引
                    dataIndexDict["curQstDataIndex"] = [];
                    dataIndexArr.push(newTmp);
                })
                return;//相当于for循环的continue;
            } else {
                tmp.children = getChildren(questions[key], tmp, dataIndexDict);
            }
        } else if("MULTIPLE" != tmp.title_type) { // 非矩阵且非多选
            tmp.options = getOptions(questions[key], tmp, srcData.JUMPCONSTRAINT_SOURCE_Q_DICT, dataIndexDict); // 选项
        } else {//多选
            tmp.options = getDataIdxMultiOption(questions[key].option_list, tmp, srcData.JUMPCONSTRAINT_SOURCE_Q_DICT, dataIndexDict);
        }
        if("DESCRIPTION" != tmp.sys_type) {//描述类占位题不生成dataIndexDict值
            tmp.data_index = dataIndexDict["curQstDataIndex"]; // 数据库索引
        }
        dataIndexDict["curQstDataIndex"] = [];

        if("DESCRIPTION" == tmp.sys_type) {//暂时不处理不显示描述类题型
            return;//相当于for循环的continue;
        }
        dataIndexArr.push(tmp);
        // }
    })
    let newDataIndexArr = convertDataIndexArr(dataIndexArr); // 转换data_index数组为wjx格式
    return newDataIndexArr;//dataIndexArr;
}

// 转换data_index数组为wjx格式
const convertDataIndexArr = function (dataIndexArr) {
    let newDataIndexArr = new Array();
    let len = getJsonLength(dataIndexArr);
    counter = 0;
    for (let i = 0; i < len; i++) {
        let curData = dataIndexArr[i];
        if ("MULTIPLE_MATRIX" == curData.sys_type ) {// 矩阵多选：拆children中的options，但option值取原来整体options
            for (let j = 0; j < curData.children.length; j++) {//遍历children
                let child = curData.children[j];
                let options = child.options;
                let optStr = JSON.stringify(options);
                for (let k = 0; k < options.length; k++) {
                    let newTmp = options[k];
                    newTmp.index = counter++;
                    newTmp.options = JSON.parse(optStr);
                    newDataIndexArr.push(newTmp);
                }
            }
        } else if ("MATRIX_TEXT" == curData.sys_type) {// 矩阵填空：拆children中的options
            curData.children.forEach(child => {
                child.options.forEach(option => {                        
                    let newTmp = option;
                    newTmp.index = counter++;
                    newTmp.options = [JSON.parse(JSON.stringify(option))];
                    newDataIndexArr.push(newTmp);
                });                    
            });
        } else if ("SINGLE_SLIDE" == curData.sys_type) {// 单选滑动条：拆options，但title和name取原来整体title和name
            curData.children.forEach(child => {
                let newTmp = child;
                newTmp.title = curData.title;
                newTmp.name = curData.name;
                newTmp.index = counter++;
                newDataIndexArr.push(newTmp);
            });
        } else if ("MATRIX" == curData.sys_type || "MULTIPLE_TEXT" == curData.sys_type || "SLIDE" == curData.sys_type ) { // 矩阵or多填题：拆children
            curData.children.forEach(child => {
                let newTmp = child;
                newTmp.index = counter++;
                newDataIndexArr.push(newTmp);
            });
        } else if ("MULTIPLE" == curData.sys_type || "SORTED" == curData.sys_type || "RATE" == curData.sys_type ) { // 多选，排序和比重题：拆options
            curData.options.forEach(option => {
                let newTmp = option;
                newTmp.index = counter++;
                newTmp.options = [JSON.parse(JSON.stringify(option))];
                newDataIndexArr.push(newTmp);
            });
        } else {
            let newTmp = curData;
            newTmp.index = counter++;
            newDataIndexArr.push(newTmp);
        }
    }
    return newDataIndexArr;
}

// 将指定json数据中的real_value替换成rl_value
const modifyRealValueToRlValue = function (jsonData) {
    let len = getJsonLength(jsonData);
    const traverse = function (obj) {
        if (typeof obj !== 'object' || obj === null) {
            return;
        }
        for (let key in obj) {
            if (obj.hasOwnProperty('real_value')) {
                obj['rl_value'] = obj['real_value'];
                delete obj['real_value'];
            } else {
                traverse(obj[key]);
            }
        }
    };
    traverse(jsonData);
    return jsonData;
}

// 获取选项option的值列表
const getOptionsValueList = function (options) {
    let valueList = new Array();
    for (let i = 0; i < options.length; i++) {
        valueList.push(options[i].value);
    }
    return valueList;
}

// 获取选项option的范围值列表
const getOptionsRangeValueList = function (curData) {
    let valueList = new Array();
    let minVal = curData.min_oper_num;
    let maxVal = curData.max_oper_num;
    for (let i = minVal; i <= maxVal; i++) {
        valueList.push(i);
    }
    return valueList;
}

// 增加valid_values字段
const addValidValues = function (dataIndexArr) {
    let len = getJsonLength(dataIndexArr);
    let sortedQstList = new Array();// 排序题列表，由于其值分散需要收集到一起
    let sortedQstValueList = [-3, -2]; // 排序题值列表
    // 根据每道题的类型添加valid_values字段
    for (let i = 0; i < len; i++) {
        let curData = dataIndexArr[i];
        if ("SINGLE" == curData.sys_type) {// 单选题
            curData.valid_values = [-3].concat(getOptionsValueList(curData.options));
        } else if ("MULTIPLE" == curData.sys_type) {// 多选题
            curData.valid_values = [-3, -2, 0, 1];
        } else if ("SINGLE_SELECT" == curData.sys_type) {// 下拉选择
            curData.valid_values = [-3, -2].concat(getOptionsValueList(curData.options));
        } else if ("SORTED" == curData.sys_type) {// 排序题
            sortedQstList.push(curData);
            sortedQstValueList = sortedQstValueList.concat(getOptionsValueList(curData.options));
        } else if ("SCALE" == curData.sys_type) {// 量表题
            curData.valid_values = [-3].concat(getOptionsValueList(curData.options));
        } else if ("MATRIX" == curData.sys_type) {// 矩阵单选
            curData.valid_values = [-3].concat(getOptionsValueList(curData.options));
        } else if ("MULTIPLE_MATRIX" == curData.sys_type) {// 矩阵多选
            curData.valid_values = [-3, -2, 0, 1];
        } else if ("SINGLE_SLIDE" == curData.sys_type) {// 单项滑动题
            curData.valid_values = getOptionsRangeValueList(curData).concat([-3]);
        } else if ("SLIDE" == curData.sys_type) {// 矩阵滑动题
            curData.valid_values = getOptionsRangeValueList(curData).concat([-3]);
        } else if ("RATE" == curData.sys_type) {// 比重题
            curData.valid_values = getOptionsRangeValueList(curData).concat([-3]);
        } else if ("DATE" == curData.sys_type) {// 日期题
            curData.valid_values = null;
        } else if ("AREA" == curData.sys_type) {// 地区题
            curData.valid_values = null;
        } else if ("TEXT" == curData.sys_type) {// 填空题
            curData.valid_values = null;
        } else if ("MULTIPLE_TEXT" == curData.sys_type) {// 多项填空
            curData.valid_values = null;
        } else if ("MATRIX_TEXT" == curData.sys_type) {// 矩阵填空
            curData.valid_values = null;
        } else {// DESCRIPTION描述类占位题
            curData.valid_values = null;
        }
    }
    // 处理排序题的valid_values字段
    for (let i = 0; i < sortedQstList.length; i++) {
        let curData = sortedQstList[i];
        curData.valid_values = sortedQstValueList;
    }
}

const fs = require('fs');
// const srcData = window.__INITIAL_STATE__;
// 加载题目主体函数定义
const getDataArr = function (sdata_file) {
    // console.log("==================================== enter js ====================================");
    let sdata = "";
    try {
        const data = fs.readFileSync(sdata_file);
        // console.log(data.toString());
        sdata = data.toString();
    } catch (err) {
        console.error(err);
    }

    let srcData = str2json(sdata);
    let result = { list: [], data_index: [], total_data_index: 0 };//list代表问卷的所有题目；data_index代表数据库对应的数据；
    let listDataArr = new Array(); // 返回的题目内容列表

    let counter = 0;
    let questions = srcData.QUESTION_DICT;
    let dataIndexDict = {"lastDataIndex" : 0, "curQstDataIndex":[]};//用于记录上一个索引，和当前题目data_index集合
    Object.keys(questions).forEach(key => { // for (let key in questions) {//
        //console.log(key);
        let tmp = new Object();
        tmp.tid = ++counter; // 题目的计数序号，唯一但不用于提交，可在relation中使用
        tmp.title_id = key; // 题目id_每个问卷每个题目唯一标识，提交用
        tmp.title = key + questions[key].title; // 题目的标题，title_id + 标题字符串
        tmp.title_type = questions[key].question_type.toString(); // 题目类型_每个平台自己的题目类型_1_23
        tmp.sys_type = getSysType(questions[key].question_type, questions[key].custom_attr, questions[key].option_list); // 内部平台题目类型
        tmp.name = questions[key].title; // 题目名称，给制单人看的
        tmp.value = ""; // 值 - 题目维度下不需要填
        tmp.is_jump = false; // 是否是跳题 "1" || True | ""
        tmp.jump_to = ""; // 跳到哪个题目 "" / title_id
        setJumpOnQstIfExist(tmp, questions[key].jumpconstraint_id_list2);
        tmp.req = getRequired(questions[key].custom_attr); // 是否必须题 "1" / "0" || ""
        tmp.is_text = isText(tmp, questions[key].custom_attr); // 是否填空题 bool
        tmp.relation = getDisplay(listDataArr, srcData, key);
        // tmp.relation = getDisplayNew(srcData.DISPLAYCONSTRAINT_SOURCE_Q_DICT, questions[key].displayconstraint_id_list2, key); // 关联哪个题目(显示逻辑) 7,1;2;3|8,2;3
        tmp.min_oper_num = 0; // 最小值
        tmp.max_oper_num = 0; // 最大值
        setMaxAndMinIfExist(tmp, questions[key]);
        tmp.rate = 0; // 权重 - 题目维度下不需要填
        tmp.text = ""; // 填空内容 - 题目维度下不需要填
        tmp.is_reverse = false; //是否反转 - 题目维度下不需要填
        tmp.options = [];
        tmp.children = [];
        if("MATRIX" == tmp.sys_type || "MULTIPLE_MATRIX" == tmp.sys_type || "MATRIX_TEXT" == tmp.sys_type
            || "MULTIPLE_TEXT" == tmp.sys_type) { // 矩阵or多填题
            if (7 == questions[key].question_type) {//矩阵打分题
                questions[key].option_list.forEach(option => { 
                    let newTmp = deepClone(tmp);
                    newTmp.title = tmp.title + "_" + option.title + "_" + option._id.$oid;
                    newTmp.children = getChildren(questions[key], newTmp, dataIndexDict);
                    newTmp.data_index = dataIndexDict["curQstDataIndex"]; // 数据库索引
                    newTmp.is_repeat = false; // 是否去重 - 题目维度下不需要填 - 对于解析来说，默认false
                    dataIndexDict["curQstDataIndex"] = [];
                    listDataArr.push(newTmp);
                })
                return;//相当于for循环的continue;
            } else {
                tmp.children = getChildren(questions[key], tmp, dataIndexDict);
            }
        } else { 
            tmp.options = getOptions(questions[key], tmp, srcData.JUMPCONSTRAINT_SOURCE_Q_DICT, dataIndexDict); // 选项
        }
        if("DESCRIPTION" != tmp.sys_type) {//描述类占位题不生成dataIndexDict值
            tmp.data_index = dataIndexDict["curQstDataIndex"]; // 数据库索引
        }
        tmp.is_repeat = false; // 是否去重 - 题目维度下不需要填 - 对于解析来说，默认false
        dataIndexDict["curQstDataIndex"] = [];

        if("DESCRIPTION" == tmp.sys_type) {//暂时不处理不显示描述类题型
            return;//相当于for循环的continue;
        }
        listDataArr.push(tmp);
    });

    result.list = modifyRealValueToRlValue(listDataArr);//相关分析需要删除real_value才能运行成功，故此处先将real_value替换成rl_value
    let dataIndexArr = getDataIndexArr(srcData);
    let newDataIndexArr = modifyRealValueToRlValue(dataIndexArr); // 相关分析需要删除real_value才能运行成功，故此处先将real_value替换成rl_value
    addValidValues(newDataIndexArr); // 增加valid_values字段
    result.data_index = newDataIndexArr;
    result.total_data_index = dataIndexDict["lastDataIndex"];
    console.log(JSON.stringify(result));
    return result;
};

getDataArr(param1);//测试结果
